<?php
require_once 'config/sidebar.conf.inc';

class Menu
{
    private $currentIndex;
    private $currentMenu;
    
    public function __construct()
    {
    
    }
    
    public function setCurrentMenu( $currentMenu )
    {
        $this->currentMenu = $currentMenu;
    }
    
    public function getMenu()
    {
        global $sidebar;
        
        foreach($sidebar as $i=>$el) {
            if ( $this->currentMenu == $el['label'] ) {
                $sidebar[$i]['css']  = 'active open';
                $sidebar[$i]['href'] = '#'; // On desactive le clic sur le menu courant
                $this->currentIndex  = $i;
            }
            if ( isset($el['submenus']) ){
                $sidebar[$i]['count_submenu'] = count($el['submenus']);
            }
        }
    
        return $sidebar;
    }
    
    public function getCurrentMenu()
    {
        global $sidebar;
        
        return array(
            'icon'  => $sidebar[$this->currentIndex]['icon'],
            'label' => $sidebar[$this->currentIndex]['label'],
        );
    }
}